
import os
import subprocess

# msdev.exe /?
#
# Usage:
#  MSDEV [myprj.dsp|mywksp.dsw]  - load project/workspace
#        [<filename>]            - load source file
#        /?                      - display usage information
#        /EX <macroname>         - execute a VBScript macro
#        /OUT <filename>         - redirect command line output to a file
#        /USEENV                 - ignore tools.options.directories settings
#        /MAKE [<target>] [...]  - build specified target(s)
#              [<project> - <platform> <configname>]
#              [[<project>|ALL] - [DEBUG|RELEASE|ALL]]
#              /CLEAN            - delete intermediate files but don't build
#              /REBUILD          - clean and build
#              /NORECURSE        - don't build dependent projects


##################################################################################

dspfile	= r'D:\me\document\VC6\DanceWorld\ECItemSee\ECItemSee.dsp'

def vc6build(dspfile, mode= 'release', isrebuild= False):

	# modeparam
	mode		= mode.lower()
	modeparam	= '"all - Win32 RELEASE"'
	if mode == 'debug':
		modeparam	= '"all - Win32 Debug"'
	elif mode == 'all':
		modeparam	= '"all - Win32 Debug" "all - Win32 Release"'

	#buildparam
	buildparam	= 'REBUILD' if isrebuild else 'BUILD'

	msdev		= os.path.join(os.getenv('msdevdir'), r'bin\msdev.exe')
	cmd			= '%s %s /MAKE %s /%s / NORECURSE'%(msdev, dspfile, modeparam, buildparam)
	subprocess.Popen(cmd)

if __name__=='__main__':
	vc6build(dspfile, 'all', True)
	





##################################################################################
'''
def get_vc6dirs():
	keypath	= r'S-1-5-21-861567501-1482476501-682003330-1003\Software\Microsoft\Devstudio\6.0\Build System\Components\Platforms\Win32 (x86)\Directories'
	key			= winreg.OpenKey(winreg.HKEY_USERS, keypath)

	pathdirs	= winreg.QueryValueEx(key, 'Path Dirs')[0]
	includedirs	= winreg.QueryValueEx(key, 'Include Dirs')[0]
	librarydirs	= winreg.QueryValueEx(key, 'Library Dirs')[0]
	sourcedirs	= winreg.QueryValueEx(key, 'Source Dirs')[0]

	#print(pathdirs, includedirs, librarydirs, sourcedirs)
	return pathdirs, includedirs, librarydirs, sourcedirs
'''
